home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LTP_DrawBox.c < prev    next >
C/C++ Source or Header  |  1995-09-29  |  5KB  |  198 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. VOID __regargs
  10. LTP_DrawMultiLineButton(struct RastPort *RPort,WORD Left,WORD Top,WORD Width,WORD Height,struct ImageInfo *ImageInfo,BOOL Bold)
  11. {
  12.     WORD Len,ThisTop,ThisLeft;
  13.     STRPTR *Lines = ImageInfo -> Lines;
  14.     WORD LineCount = ImageInfo -> LineCount;
  15.     STRPTR KeyStroke = ImageInfo -> KeyStroke;
  16.     STRPTR Label;
  17.     ULONG OldStyle,StyleFlags;
  18.  
  19.     if(Bold)
  20.     {
  21.         StyleFlags = FSF_BOLD;
  22.  
  23.         OldStyle = SetSoftStyle(RPort,FSF_BOLD,AskSoftStyle(RPort));
  24.     }
  25.     else
  26.         StyleFlags = NULL;
  27.  
  28.     if(!LineCount)
  29.         LineCount = 1;
  30.  
  31.     ThisTop = Top + (Height - LineCount * RPort -> TxHeight + 1) / 2 + RPort -> TxBaseline;
  32.  
  33.     do
  34.     {
  35.         if(LineCount && Lines)
  36.             Label = *Lines++;
  37.         else
  38.             Label = ImageInfo -> Label;
  39.  
  40.         Len = strlen(Label);
  41.  
  42.         ThisLeft = Left + (Width - TextLength(RPort,Label,Len)) / 2;
  43.  
  44.         Move(RPort,ThisLeft,ThisTop);
  45.         Text(RPort,Label,Len);
  46.  
  47.         if(KeyStroke)
  48.         {
  49.             if(KeyStroke >= Label && KeyStroke < Label + Len)
  50.             {
  51.                 ULONG OldStyle;
  52.  
  53.                 if(KeyStroke != Label)
  54.                     ThisLeft += TextLength(RPort,Label,(ULONG)KeyStroke - (ULONG)(Label));
  55.  
  56.                 OldStyle = SetSoftStyle(RPort,FSF_UNDERLINED | StyleFlags,AskSoftStyle(RPort));
  57.  
  58.                 Move(RPort,ThisLeft,ThisTop);
  59.                 Text(RPort,KeyStroke,1);
  60.  
  61.                 SetSoftStyle(RPort,StyleFlags | OldStyle & ~FSF_UNDERLINED,OldStyle);
  62.  
  63.                 KeyStroke = NULL;
  64.             }
  65.         }
  66.  
  67.         ThisTop += RPort -> TxHeight;
  68.     }
  69.     while(--LineCount > 0);
  70.  
  71.     if(Bold)
  72.         SetSoftStyle(RPort,OldStyle & ~FSF_BOLD,OldStyle);
  73. }
  74.  
  75. VOID __regargs
  76. LTP_DrawBox(struct RastPort *rp,struct DrawInfo *drawInfo,LONG left,LONG top,LONG width,LONG height,BOOLEAN selected,BOOLEAN ghosted,ImageInfo *imageInfo)
  77. {
  78.     UWORD        *pens = drawInfo -> dri_Pens;
  79.     UWORD         pen1,pen2,pen3,pen4;
  80.     ImageTypes     imageType = imageInfo -> ImageType;
  81.  
  82.     if(selected)
  83.     {
  84.         pen1 = SHADOWPEN;
  85.         pen2 = SHINEPEN;
  86.         pen3 = FILLPEN;
  87.         pen4 = FILLTEXTPEN;
  88.     }
  89.     else
  90.     {
  91.         pen1 = SHINEPEN;
  92.         pen2 = SHADOWPEN;
  93.         pen3 = BACKGROUNDPEN;
  94.         pen4 = TEXTPEN;
  95.     }
  96.  
  97.     LTP_SetPens(rp,pens[pen1],0,JAM1);
  98.     Move(rp,left + 1,top + 1);
  99.     Draw(rp,left + 1,top + height - 2);
  100.     Draw(rp,left,top + height - 1);
  101.     Draw(rp,left,top);
  102.     Draw(rp,left + width - 2,top);
  103.  
  104.     if(imageInfo -> Emboss)
  105.     {
  106.         Move(rp,left + 2,top + height - 3);
  107.         Draw(rp,left + 2,top + 1);
  108.         Draw(rp,left + width - 3,top + 1);
  109.  
  110. /*        Move(rp,left + 3,top + height - 4);*/
  111. /*        Draw(rp,left + 3,top + 2);*/
  112. /*        Draw(rp,left + width - 4,top + 2);*/
  113.     }
  114.  
  115.     LTP_SetAPen(rp,pens[pen2]);
  116.     Move(rp,left + width - 2,top + height - 2);
  117.     Draw(rp,left + width - 2,top + 1);
  118.     Draw(rp,left + width - 1,top);
  119.     Draw(rp,left + width - 1,top + height - 1);
  120.     Draw(rp,left + 1,top + height - 1);
  121.  
  122.     if(imageInfo -> Emboss)
  123.     {
  124.         Move(rp,left + width - 3,top + 2);
  125.         Draw(rp,left + width - 3,top + height - 2);
  126.         Draw(rp,left + 2,top + height - 2);
  127.  
  128. /*        Move(rp,left + width - 4,top + 3);*/
  129. /*        Draw(rp,left + width - 4,top + height - 3);*/
  130. /*        Draw(rp,left + 3,top + height - 3);*/
  131.     }
  132.  
  133.     LTP_SetAPen(rp,pens[pen3]);
  134.  
  135.     if(imageInfo -> Emboss)
  136.     {
  137.         RectFill(rp,left + 3,top + 2,left + 2 + width - 6,top + 1 + height - 4);
  138. /*        RectFill(rp,left + 4,top + 3,left + 2 + width - 7,top + 1 + height - 5);*/
  139.     }
  140.     else
  141.         RectFill(rp,left + 2,top + 1,left + 2 + width - 5,top + 1 + height - 3);
  142.  
  143.     LTP_SetAPen(rp,pens[pen4]);
  144.  
  145.     switch(imageType)
  146.     {
  147.         case IMAGECLASS_PICKER:
  148.         {
  149.             LONG    Left    = left + 4,
  150.                 Top    = top + 2,
  151.                 Width    = width - 8,
  152.                 Height    = height - 4;
  153.  
  154.             LTP_DrawPicker(rp,FALSE,Left,Top,Width,Height);
  155.             break;
  156.         }
  157.  
  158.         case IMAGECLASS_MULTILINEBUTTON:
  159.  
  160.             if(imageInfo -> Emboss)
  161.                 LTP_DrawMultiLineButton(rp,left + 5,top + 3,width - 10,height - 6,imageInfo,TRUE);
  162.             else
  163.                 LTP_DrawMultiLineButton(rp,left + 4,top + 2,width - 8,height - 4,imageInfo,FALSE);
  164.  
  165.             break;
  166.  
  167.         case IMAGECLASS_LEFTINCREMENTER:
  168.         case IMAGECLASS_RIGHTINCREMENTER:
  169.  
  170.             LTP_DrawIncrementer(rp,imageType == IMAGECLASS_LEFTINCREMENTER,left + 2,top + 1,width - 4,height - 2);
  171.             break;
  172. #ifdef DO_TAPEDECK_KIND
  173.         case IMAGECLASS_BACKWARD:
  174.         case IMAGECLASS_FORWARD:
  175.         case IMAGECLASS_PREVIOUS:
  176.         case IMAGECLASS_NEXT:
  177.         case IMAGECLASS_RECORD:
  178.         case IMAGECLASS_PLAY:
  179.         case IMAGECLASS_STOP:
  180.         case IMAGECLASS_PAUSE:
  181.         case IMAGECLASS_EJECT:
  182.         case IMAGECLASS_REWIND:
  183.  
  184.             LTP_DrawTapeButton(rp,imageInfo,left,top,width,height,drawInfo -> dri_Resolution . X,drawInfo -> dri_Resolution . Y,pens[pen3]);
  185.             break;
  186. #endif    /* DO_TAPEDECK_KIND */
  187.     }
  188.  
  189.     if(ghosted)
  190.     {
  191.         LTP_SetAPen(rp,pens[BACKGROUNDPEN]);
  192.  
  193.         SetAfPt(rp,(UWORD *)&checkPat,1);
  194.         RectFill(rp,left,top,left + width - 1,top + height - 1);
  195.         SetAfPt(rp,NULL,0);
  196.     }
  197. }
  198.